package com.czxy.controller;

import com.czxy.service.CommentService;
import com.czxy.vo.CommentResult;
import com.czxy.vo.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张青卯
 */
@RestController
@RequestMapping
public class CommentController {

    private final CommentService commentService;

    @Autowired
    public CommentController(CommentService commentService) {
        this.commentService = commentService;
    }

    @GetMapping("/comments/{spuid}")
    public ResponseEntity<Object> findCommentPageById(@PathVariable("spuid") Integer spuid, PageRequest pageRequest){
        CommentResult result = commentService.findPageById(spuid, pageRequest);
        return ResponseEntity.ok(result);
    }
}
